// 字面量   json     对象
var student={
    id:10001,
    name:"张三",
    scores:[
        {subject:"html",score:90},
        {subject:"js",score:80}
    ]
}


// function
function student(id,name){
    this.id=id;
    this.name=name;
    this.scores=[
        {subject:"html",score:90},
        {subject:"js",score:80}
    ]
}
// 扩展
student.prototype.sex="男";
student.prototype.eat=function(foot){
console.log("吃"+foot);
}
//添加
var stu=new student(10001,"张三");
stu.eat("米饭");
console.log(stu.sex);


//object
var stu2=new Object();
stu2.id=1000;
stu2.name="张三";
stu2.scores=[
    {subject:"html",score:90},
    {subject:"js",score:80}
]
console.log(stu2.scores[0]["subject"]);




function student(id,name){
    this.id=id;
    this.name=name;
   this.eat=function(foot){
       console.log("吃"+foot);
       return this;
   }
   this.sleep=function(){
       console.log("睡");
       return this;
   }
}
var stu=new student(1001,"张三");
// 链式编程
stu.eat("").sleep().eat("").sleep();
